$(function () {

    $('#verifyImg').click(function () {
        $('#verifyImg').attr('src','../verify?'+Math.random());
    });

    //注册发送请求
    $('#btn').click(function () {
        var usernameVal = $('#username-in').val();
        var passwordVal = $('#password-in').val();
        var rePasswordVal = $('#rePassword-in').val();
        var emailVal = $('#email-in').val();
        var verifyVal = $('#verify').val();
        if(passwordVal!=rePasswordVal){
           alert("两次密码不一致");
            return;
        }
        var con = {
            username:usernameVal,
            password:passwordVal,
            email:emailVal,
            verify:verifyVal
        };
        $.post(
            '../register',
            con,
            function (data) {
                var result = JSON.parse(data);
               alert(result.message);
                $('#verifyImg').load();
            }
        );
        $('#verifyImg').attr('src','../verify?'+Math.random());
    });

});